package cn.tx.controller;

import cn.tx.constant.MessageConstant;
import cn.tx.constant.RedisMessageConstant;
import cn.tx.entity.Result;
import cn.tx.service.SmsService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Snake Eyes
 * @PROJECT_NAME: health_parent
 * @DESCRIPTION: 短信发送模块
 * @USER: 11647
 * @DATE: 2021/9/4 8:59
 * @Email: 1164763541@qq.com
 */
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Reference
    private SmsService smsService;

    /**
     * @author :11647
     * @date ：Created in 2021/9/6  15:22
     * @description：(描述) 体检预约发送验证码
     * @modified By：11647
     * @version:
     */
    @RequestMapping("/sendCode.do")
    public Result orderSendCode(String phone) {
        try {
         smsService.sendRedis(phone);
            return new Result(true, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        }
    }
    @RequestMapping("send4Login.do")
    public Result loginSaveCode(String telephone){
        try {
            smsService.loginSendRedis(telephone);
            return new Result(true, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.SEND_VALIDATECODE_SUCCESS);
        }

    }
}
